$converged = RotationCalculation$($A[M][N]$ : matrix, $[lb_i, ub_i]$ : row block $i$, $[lb_j, ub_j]$ : row block $j$, $\delta$)

\begin{algorithmic}
\STATE $G[R][R] = 0, \Theta_i[R] = 0, \Theta_i[R] = 0$
\STATE $converged \gets true$
\FOR{$k = 1$ to $N$}
  \FOR{$i=lb_i$ to $ub_i$}
    \STATE $\Theta_i[i \mod R] \gets \Theta_i[i \mod R] + A_{i, k}^2$
    \FOR{$j=lb_j$ to $ub_j$}
      \IF{$i < j$}
        \STATE $G[i \mod R][j \mod R] \gets G[i \mod R][j \mod R] + A_{i, k} \cdot A_{j, k}$
      \ENDIF
    \ENDFOR
    \FOR{$j=lb_j$ to $ub_j$}
      \STATE $\Theta_j[j \mod R] \gets \Theta_j[j \mod R] + A_{j, k}^2$
    \ENDFOR
  \ENDFOR
\ENDFOR

\FOR{$i=lb_i$ to $ub_i$}
  \FOR{$j=lb_j$ to $ub_j$}
    \IF{$i < j$}
      \IF{$|g| > \epsilon$}
        \STATE $converged \gets false$
      \ENDIF
      \IF{$|g| > \delta$}
        \STATE $P[j \mod R][k \mod R] \gets jacobi(\Theta_i[j \mod R], \Theta_j[k \mod R], G[j \mod R][k \mod R])$
      \ELSE
        \STATE $P[j \mod R][k \mod R] \gets 1, 0$
      \ENDIF
    \ENDIF
  \ENDFOR
\ENDFOR
\end{algorithmic}